load(
    "//tools:defaults.bzl",
    "extract_tokens",
    "markdown_to_html",
    "ng_project",
    "ng_web_test_suite",
    "sass_binary",
    "sass_library",
)

package(default_visibility = ["//visibility:public"])

sass_library(
    name = "m3",
    srcs = [
        "_m3-datepicker.scss",
    ],
    deps = [
        "//src/material/core/style:sass_utils",
        "//src/material/core/tokens:m3_utils",
    ],
)

sass_library(
    name = "m2",
    srcs = [
        "_m2-datepicker.scss",
    ],
    deps = [
        "//src/material/core/style:elevation",
        "//src/material/core/style:sass_utils",
        "//src/material/core/theming:_inspection",
        "//src/material/core/tokens:m2_utils",
    ],
)

sass_library(
    name = "theme",
    srcs = [
        "_datepicker-theme.scss",
    ],
    deps = [
        ":m2",
        "//src/material/button:icon_button_theme",
        "//src/material/core/style:sass_utils",
        "//src/material/core/theming",
        "//src/material/core/theming:_inspection",
        "//src/material/core/theming:_validation",
        "//src/material/core/tokens:token_utils",
        "//src/material/core/typography",
    ],
)

sass_library(
    name = "datepicker_legacy_compat",
    srcs = ["_datepicker-legacy-compat.scss"],
    deps = [
        "//src/material/button:icon_button_theme",
        "//src/material/button:theme",
    ],
)

sass_binary(
    name = "datepicker_content_css",
    src = "datepicker-content.scss",
    deps = [
        ":m2",
        "//src/material/core/tokens:token_utils",
    ],
)

sass_binary(
    name = "calendar_css",
    src = "calendar.scss",
    deps = [
        ":m2",
        "//src/cdk:sass_lib",
        "//src/material/core/focus-indicators",
        "//src/material/core/tokens:token_utils",
    ],
)

sass_binary(
    name = "calendar_body_css",
    src = "calendar-body.scss",
    deps = [
        ":m2",
        "//src/cdk:sass_lib",
        "//src/material/core/style:button_common",
        "//src/material/core/tokens:token_utils",
    ],
)

sass_binary(
    name = "datepicker_toggle_css",
    src = "datepicker-toggle.scss",
    deps = [
        ":m2",
        "//src/cdk:sass_lib",
        "//src/material/core/tokens:token_utils",
    ],
)

sass_binary(
    name = "datepicker_actions_css",
    src = "datepicker-actions.scss",
)

sass_binary(
    name = "date_range_input_css",
    src = "date-range-input.scss",
    deps = [
        ":m2",
        "//src/cdk:sass_lib",
        "//src/material/core/style:variables",
        "//src/material/core/style:vendor_prefixes",
        "//src/material/core/tokens:token_utils",
    ],
)

ng_project(
    name = "datepicker",
    srcs = [
        "aria-accessible-name.ts",
        "calendar.ts",
        "calendar-body.ts",
        "date-range-input.ts",
        "date-range-input-parts.ts",
        "date-range-picker.ts",
        "date-range-selection-strategy.ts",
        "date-selection-model.ts",
        "datepicker.ts",
        "datepicker-actions.ts",
        "datepicker-base.ts",
        "datepicker-errors.ts",
        "datepicker-input.ts",
        "datepicker-input-base.ts",
        "datepicker-intl.ts",
        "datepicker-module.ts",
        "datepicker-toggle.ts",
        "index.ts",
        "month-view.ts",
        "multi-year-view.ts",
        "public-api.ts",
        "year-view.ts",
    ],
    assets = [
        "calendar-body.html",
        "calendar-header.html",
        "calendar.html",
        "date-range-input.html",
        "datepicker-content.html",
        "datepicker-toggle.html",
        "month-view.html",
        "multi-year-view.html",
        "year-view.html",
        ":datepicker_actions_css",
        ":datepicker_content_css",
        ":datepicker_toggle_css",
        ":date_range_input_css",
        ":calendar_css",
        ":calendar_body_css",
    ],
    deps = [
        "//:node_modules/@angular/common",
        "//:node_modules/@angular/core",
        "//:node_modules/@angular/forms",
        "//:node_modules/rxjs",
        "//src:dev_mode_types",
        "//src/cdk/a11y",
        "//src/cdk/bidi",
        "//src/cdk/coercion",
        "//src/cdk/keycodes",
        "//src/cdk/overlay",
        "//src/cdk/platform",
        "//src/cdk/portal",
        "//src/material/button",
        "//src/material/core",
        "//src/material/form-field",
        "//src/material/input",
        "//src/material/tooltip",
    ],
)

ng_project(
    name = "unit_test_sources",
    testonly = True,
    srcs = glob(
        ["**/*.spec.ts"],
        exclude = ["**/*.e2e.spec.ts"],
    ),
    deps = [
        ":datepicker",
        "//:node_modules/@angular/common",
        "//:node_modules/@angular/core",
        "//:node_modules/@angular/forms",
        "//:node_modules/@angular/platform-browser",
        "//:node_modules/rxjs",
        "//src/cdk/a11y",
        "//src/cdk/bidi",
        "//src/cdk/keycodes",
        "//src/cdk/overlay",
        "//src/cdk/platform",
        "//src/cdk/scrolling",
        "//src/cdk/testing/private",
        "//src/material/button",
        "//src/material/core",
        "//src/material/form-field",
        "//src/material/input",
        "//src/material/testing",
    ],
)

ng_web_test_suite(
    name = "unit_tests",
    deps = [":unit_test_sources"],
)

markdown_to_html(
    name = "overview",
    srcs = [":datepicker.md"],
)

extract_tokens(
    name = "tokens",
    srcs = [":theme"],
)

filegroup(
    name = "source-files",
    srcs = glob(["**/*.ts"]),
)
